package org.two;

import java.io.*;

/**
 * Created by Administrator on 2016/3/14 0014.
 */
public class TestFileStream {
    public static void main(String[] args) throws IOException {
        String dir = System.getProperty("user.dir");
        String s = File.separator;
        File f = new File( dir + s + "progarm.mp4");
        InputStream is = new FileInputStream(f);     // 输入路径
        OutputStream os = new FileOutputStream(dir + s + "new.mp4");   // 输出路径
        double size = is.available();      // 获得文件的大小
        byte[] b = new byte[1024];      // 定义一个数组用来当做缓冲区
        int number = 0;     // 每次读取读到的内容
        int totalNumber = 0;       // 总读取量
        // 向byte数组中读取并将读取到的结果存入到number中
        while ( (number = is.read(b)) != -1 ) {
            os.write(b);
            totalNumber+=number;        // 总读取量
            System.out.format("%4.2f％\n",totalNumber/size * 100);
        }

        is.close();
        os.close();

    }
}
